package com.example.demo;

import org.redisson.Redisson;
import org.redisson.config.Config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;

@SpringBootApplication
public class Demo2Application {

    public static void main(String[] args) {

        SpringApplication.run(Demo2Application.class, args);
    }

    @Bean
//    @Primary // 确保 Redisson 作为首选的 Redis 客户端
    public Redisson redisson() {
        // 此为单机模式，支持 sentinel ,cluster
        Config config = new Config();
        config.useSingleServer().setAddress("redis://378h31e832.wicp.vip:28021").setDatabase(0).setPassword("redis123");
        //config.setLockWatchdogTimeout(1000);   //设置分布式锁超时时间
        return (Redisson) Redisson.create(config);    //返回一个Redisson对象 注入到spring中，记得使用@Bean
    }

}
